﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace MetaSharp.Transformation.Tests
{
    static class Helpers
    {
        public static void WaitForThrow<T>(this Task<IMatch> task) where T : Exception
        {
            Assert.Throws<T>(() =>
            {
                try
                {
                    task.Wait();
                }
                catch (AggregateException e)
                {
                    if (e.InnerExceptions.Count == 1)
                        throw e.InnerException;
                    throw;
                }
            });
        }
    }
}
